home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / IMED256.ARJ / SP256C.C < prev    next >
C/C++ Source or Header  |  1991-03-27  |  2KB  |  74 lines

  1. /* Example of 256 colour animation of images from IMED256 */
  2. /* Requires VGA and Microsoft C V6 */
  3. #include <conio.h>
  4. #include <graph.h>
  5. #include <stdio.h>
  6.  
  7. /* This is the standard size for a 24x48 image */
  8. #define IMAGSIZE 1156
  9.  
  10. /* Buffer for 4 images */
  11. char images[4][IMAGSIZE];
  12.  
  13. void main(void);
  14. void noimage(void);
  15.  
  16. void main()
  17. {
  18.   int i,j;
  19.   FILE *f;
  20.   if (!_setvideomode(_MRES256COLOR))
  21.     {
  22.     fprintf(stderr,"\nYou need a system which supports 256 colour 320x200 mode");
  23.     exit(1);
  24.     }
  25.  
  26.  
  27.   f=fopen("s1col.img","rb");
  28.   if (f==NULL)
  29.     noimage();
  30.   for (i=0;i<IMAGSIZE;i++)
  31.     images[0][i]=(unsigned char)getc(f);
  32.   fclose(f);
  33.  
  34.   f=fopen("s2col.img","rb");
  35.   if (f==NULL)
  36.     noimage();
  37.   for (i=0;i<IMAGSIZE;i++)
  38.     images[1][i]=(unsigned char)getc(f);
  39.   fclose(f);
  40.  
  41.   f=fopen("s3col.img","rb");
  42.   if (f==NULL)
  43.     noimage();
  44.   for (i=0;i<IMAGSIZE;i++)
  45.     images[2][i]=(unsigned char)getc(f);
  46.   fclose(f);
  47.  
  48.   f=fopen("s4col.img","rb");
  49.   if (f==NULL)
  50.     noimage();
  51.   for (i=0;i<IMAGSIZE;i++)
  52.     images[3][i]=(unsigned char)getc(f);
  53.   fclose(f);
  54.  
  55.   /* Display images until user presses a key */
  56.   while (!kbhit())
  57.     {
  58.     for (i=0;i<4;i++)
  59.       {
  60.       _putimage(0,0,(char far *)images[i],_GPSET);
  61.       for (j=0;j<30000;j++);
  62.       }
  63.     }
  64.   _setvideomode(_DEFAULTMODE);
  65. }
  66.  
  67. void noimage(void)
  68. {
  69.   _setvideomode(_DEFAULTMODE);
  70.   fprintf(stderr,"You must have\ns1col.img\ns2col.img\ns3col.img\
  71.     \nand s4col.img\nin the current directory");
  72.   exit(1);
  73. }
  74.